package d9_com.itheima.Date_jdk8;

import java.time.LocalDate;

public class Test1_LocalDate {
    public static void main(String[] args) {
        //0、获取本地日期对象
        LocalDate id = LocalDate.now();//年 月 日
        System.out.println(id);

        //1、获取日期对象中的信息
        int year = id.getYear();//年
        int month = id.getMonthValue();//月(1-12)
        int day = id.getDayOfMonth();//日
        int dayofYear = id.getDayOfYear();// 一年中的第几天
        int dayofWeek = id.getDayOfWeek().getValue();//星期几
        System.out.println(year);
        System.out.println(day);
        System.out.println(dayofWeek);

        //2、直接修改某个信息:withYear、withMonth、withDayOfMonth、withDayofYear
        LocalDate id1 = id.withYear(2099);
        LocalDate id2 = id.withMonth(12);
        System.out.println(id2);
        System.out.println(id1);

        //3、把某个信息加多少:plusYears、plusMonths、plusDays、plusWeeks
        LocalDate id3 = id.plusYears(2);
        LocalDate ld5 = id.plusMonths(2);

        //4、把某个信息减多少:minusYears、minusMonths、minusDays、minusWeeks
        LocalDate id6 = id.minusYears(2);
        LocalDate id7 = id.minusMonths(2);

        //5、获取指定日期的LocalDate对象:public static LocalDate of(int year int month int dayOfMonth)
        LocalDate id8=LocalDate.of(2099,12,12);
        LocalDate id9=LocalDate.of(2099,12,12);

        //6、判断2个日期对象，是否相等，在前还是在后:equals isBefore isAfter
        System.out.println(id8.equals(id9));//true
        System.out.println(id8.isAfter(id));//true
        System.out.println(id8.isBefore(id)); //false
    }

}
